# Sets the minimum version of CMake required to build the native
# library. You should either keep the default value or only pass a
# value of 3.4.0 or lower.

cmake_minimum_required(VERSION 3.4.1)

project("l1-lib")

set(ext_lib_dir ${CMAKE_SOURCE_DIR}/libs)

include_directories(
        src/main/jni
        src/main/jni/util
        src/main/jni/app
        src/main/jni/android_inter
)

# 将当前 "./src/main/jni" 目录下的所有源文件保存到 "NATIVE_SRC" 中，然后在 add_library 方法调用。
aux_source_directory( ./src/main/jni/app APP_SRC )
aux_source_directory( ./src/main/jni/android_inter ANDROID_INTER_SRC )

file(GLOB APP_SRC "src/main/jni/app/*.c")
file(GLOB ANDROID_INTER_SRC "src/main/jni/android_inter/*.c")

add_library( # Sets the name of the library.
            l1-lib

             # Sets the library as a shared library.
             SHARED

             src/main/jni/jnihelper.c
             src/main/jni/PosNative.c
             src/main/jni/PosCallback.c
             ${ANDROID_INTER_SRC}
             ${APP_SRC}
             # Provides a relative path to your source file(s).

             )

find_library( # Sets the name of the path variable.
              log-lib

              # Specifies the name of the NDK library that
              # you want CMake to locate.
              log )

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in the
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
                       l1-lib
                       ${ext_lib_dir}/${ANDROID_ABI}/lib_ddi.so
                       ${log-lib} )